package com.candy.control;

import com.candy.dao.DBDriver2;
import com.candy.service.UserInfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.LinkedList;

@WebServlet("/getUserInfoById")
public class GetOneUserInfoServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        接收前端传递进来的参数
        int userId=Integer.parseInt(req.getParameter("id"));
//        调用业务逻辑处理层
        UserInfoService service=new UserInfoService();
        LinkedList<LinkedHashMap<String,Object>> userInfo= service.getUserInfoById(userId);
//        将数据存储在session中
        req.getSession().setAttribute("userinfoByID",userInfo);
//        跳转到更新页面
        req.getRequestDispatcher("updateUserinfo.jsp").forward(req,resp);
    }
}
